<template>
	<!--通告详细-->
	<view class="page-content">
		<view class="page-body">
			<view class="input-row">
				<input class="input-row-w" type="text" v-model="params.title" placeholder="请输入标题"
					placeholder-style="color:#999"></input>
			</view>
			<view class="input-row2">
				<textarea class="input-row-w" v-model="params.txt" placeholder-style="color:#999" placeholder="请输入内容" />
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex';
	import { addNotepads } from '@/common/api.js'
	
	export default {
		components: {},
		data() {
			return {
				params: {
					title: '',
					txt: ''
				}
			}
		},
		onLoad(option) {
			console.log(222, option)
		},
		computed: {
			...mapGetters(['companyInfo','selIndex'])
		},
		onNavigationBarButtonTap(e) {
			console.log(23, e)
			if (e.index == 0) {
				this.adds()
			}
		},
		methods: {
			adds() {
				let params = {
					company_id: this.companyInfo.id,
					title: this.params.title,
					content: this.params.txt,
				};
				addNotepads(params).then(res=> {
					if(res.code === 2000){
						uni.showToast({
							icon: 'none',
							title:'添加成功'
						})
						setTimeout(() =>{
							uni.navigateBack({
								delta:1
							})
						},1000)
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.page-content {
		width: 100vw;
		height: 100%;
		background: $uni-bg-color-grey;

		.page-body {
			display: flex;
			flex-direction: column;
			background: $uni-bg-color;

			.input-row {
				margin: 0 30rpx;
				padding: 20rpx 0;
				height: 100rpx;
				display: flex;
				align-items: center;
				width: 100%;
				flex-direction: row;
				border-bottom: 1rpx solid #f5f5f5;

				.input-row-w {
					height: 60rpx;
					display: flex;
					flex: 1;
					width: 100%;
					color: $font-color-3;
					font-size: 32rpx;
				}
			}

			.input-row2 {
				margin: 0 30rpx;
				padding: 20rpx 0;
				height: 360rpx;
				display: flex;
				width: 100%;
				flex-direction: row;
				border-bottom: 1rpx solid #f5f5f5;

				.input-row-w {
					display: flex;
					height: 320rpx;
					flex: 1;
					width: 100%;
					color: $font-color-3;
					font-size: 32rpx;
				}
			}
		}
	}
</style>
